package com.aaa.fpa.controller;

import com.aaa.fpa.service.PlanService;
import com.aaa.pojo.Page;
import com.aaa.pojo.Plan;
import com.aaa.pojo.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
@RequestMapping("/plan")
@ResponseBody
public class PlanController {
        @Autowired
    private PlanService planService;
        @RequestMapping("/findAllpn")
        public ResultBean findAllpn(Page page,Plan plan){

            return planService.findAllpn(page,plan);
        }
        @RequestMapping("/updatepn")
    public  int updatepn(Plan plan){

            plan.setUpdate_time(new Date());
            return planService.updatepn(plan);
        }
        @RequestMapping("deletepn")
    public int deletepn(int id){

            return planService.deletepn(id);
        }
        @RequestMapping("/savepn")
    public  int savepn(Plan plan){
            plan.setCreate_time(new Date());
            plan.setTest_code((int) ((Math.random() * 9 + 1) * 100000));
            return planService.savepn(plan);
        }
        @RequestMapping("/deletespn")
    public  int deletespn(@RequestParam int[] id){
            return planService.deletespn(id);
        }
}
